﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace 毕业设计__排课软件
{
    /// <summary>
    /// QR.xaml 的交互逻辑
    /// </summary>
    public partial class QR : Window
    {
        string dbpath = string.Empty;
        string dbpath2 = string.Empty;
        string dbpath3 = string.Empty;
        string dbpath4 = string.Empty;
        public QR()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var path0 = Environment.CurrentDirectory;
            var path1 = path0.Substring(0, path0.LastIndexOf("\\", StringComparison.Ordinal));
            var path2 = path1.Substring(0, path1.LastIndexOf("\\", StringComparison.Ordinal));
            dbpath = path2 + "\\DB\\bs_pk.db";
            dbpath2 = path2 + "\\DB\\new_db\\bs_pk.db";
            dbpath4 = path2 + "\\DB\\old_db\\bs_pk" + DateTime.Now.ToString("yyMMddhhmmss") +".db";




            /*MessageBox.Show(path0);
            MessageBox.Show(path1);
            MessageBox.Show(path2);
            MessageBox.Show(dbpath);*/
            if (File.Exists(dbpath))
            {

                File.Move(dbpath, dbpath4);
            }
            else
            {
                MessageBox.Show("未知错误，真可怕");
            }



            if (File.Exists(dbpath2))
            {
                File.Copy(dbpath2, dbpath, true);
                MessageBox.Show("已经把信息删除完了，重新导入吧。");
            }
            else
            {
                MessageBox.Show("完蛋了新的数据库不见了，得联系程序管理人员");
            }

            Close();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
